//
//  SAContactModel.m
//  AddressBook
//
//  Created by 解晓东 on 15/11/7.
//  Copyright (c) 2015年 sasa. All rights reserved.
//

#import "SAContactModel.h"

@implementation SAContactModel

/*
 将某个对象写入文件时会调用
 在这个方法中说清楚哪些属性需要存储s
 */
- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:self.name forKey:@"name"];
    [encoder encodeObject:self.phone forKey:@"phone"];
}

/*
 解析对象会调用这个方法
 需要解析哪些属性
 */
- (id)initWithCoder:(NSCoder *)decoder {
    if (self == [super init]) {
        self.name = [decoder decodeObjectForKey:@"name"];
        self.phone = [decoder decodeObjectForKey:@"phone"];
    }
    
    return self;
}

@end
